﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcmyjobs.Web.Controls
{
    public partial class GridHunterJobs : System.Web.UI.UserControl
    {
        private bool _isAspPager;
        private int _atid;
        private int _disCount;
        /// <summary>
        /// 每页显示条数
        /// </summary>
        public int disCount
        {
            get { return _disCount; }
            set { _disCount = value; }
        }

        /// <summary>
        /// 网站
        /// </summary>
        public int atid
        {
            get { return _atid; }
            set { _atid = value; }
        }
        /// <summary>
        /// 是否显示翻页控件
        /// </summary>
        public bool isAspPager
        {
            get { return _isAspPager; }
            set { _isAspPager = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Application["webid"] != null)
                {
                    Bind(Convert.ToInt32(Application["webid"]));
                }
            }
           
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
           
            if (Application["webid"] != null)
            {
                this.isAspPager = true;
                this.disCount = 20;
                Bind(Convert.ToInt32(Application["webid"]));
            }
        }

        private void Bind(int atid)
        {
            //int count = 0;
            //DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetJobsInfoByCondition("hunter", atid, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out count);

            int c_isfrist = 0;
            int c_reward = 0;
            int c_vip = 0;
            int c_hunter = 0;
            int c_newjob = 0;
            int c_workerclass = 0;
            DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetJobsInfo(false,false,true, false, false, false,
                                                atid, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize,
                                                out c_isfrist, out c_reward, out c_hunter, out c_vip, out c_newjob, out c_workerclass);


            this.AspNetPager1.RecordCount = c_hunter;
            this.AspNetPager1.Visible = isAspPager;
            
            this.AspNetPager1.PageSize = disCount;

            this.gv_hunterJobs.DataSource = ds;
            this.gv_hunterJobs.DataBind();

          
        }
        public string GetBH(string str)
        {
            return "L"+str.ToString().PadLeft(6, '0');
        }
        public string GetZW(string str, int length)
        {
            if (str.Length > length)
            {
                return str.Substring(0, length) + "...";
            }
            else
            {
                return str;
            }
        }

    }
}